/**
 * 
 */
package componentEnhancement;

import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import cii_lib.CCII_ACCESS_INTERF;
import cii_lib.CCII_ACCESS_PARAM;

/**
 * @author pdrabik
 *
 */
public class ContextUtils {

	 private Vector<CCII_ACCESS_INTERF> interfaces = new Vector<CCII_ACCESS_INTERF>();
	 private Vector<CCII_ACCESS_PARAM> params = new Vector<CCII_ACCESS_PARAM>();
	 
	 private HashMap<String, CCII_ACCESS_INTERF> mapInterf = new HashMap<String, CCII_ACCESS_INTERF>();
	 protected HashMap<String, CCII_ACCESS_PARAM> mapParam = new HashMap<String, CCII_ACCESS_PARAM>();
	 
	 public ContextUtils() {}
	 
	 public ContextUtils(Vector<CCII_ACCESS_INTERF> argI, Vector<CCII_ACCESS_PARAM> argP) {
		 interfaces = argI;
		 params = argP;
		 for (int i=0; i< argI.size();i++) {
			 CCII_ACCESS_INTERF tmp = argI.get(i);
			 mapInterf.put(tmp.Name(), tmp);
		 }
		 for (int i=0; i< argP.size();i++) {
			 CCII_ACCESS_PARAM tmp = argP.get(i);
			 mapParam.put(tmp.Name(), tmp);
		 }

	 }
	 public CCII_ACCESS_PARAM getParamByName(String key) {
		 if (mapParam.size()>0) return mapParam.get(key);
		 else {
			 for (int i=0; i<params.size(); i++) {
				 CCII_ACCESS_PARAM tmp =params.get(i);
				 if (tmp.GetItem().Name==key) return tmp;
			 }
			 return null;
		 }
	 }
	 public CCII_ACCESS_INTERF getInterfByName(String key) {
		 if (mapInterf.size()>0) return mapInterf.get(key);
		 else {
			 for (int i=0; i<params.size(); i++) {
				 CCII_ACCESS_INTERF tmp =interfaces.get(i);
				 if (tmp.GetItem().Name==key) return tmp;
			 }
			 return null;
		 }
	 }
	 
	 public HashMap<String, CCII_ACCESS_INTERF> getInterfaceMap() {
		 return mapInterf;
	 }
	 public HashMap<String, CCII_ACCESS_PARAM> getParamsMap() {
		 return mapParam;
	 }
	 
}
